package cn.bonoon.kernel.io.authority;

import cn.bonoon.kernel.io.HttpStorageFile;

public class RemoteAuthorityHandler extends AbstractAuthorityRedirect implements FileAuthorityHandler{

	@Override
	public boolean accept(String code) {
		return this.catalog.equals(code);
	}

	@Override
	public int parse(HttpStorageFile hsFile) {
		String targetUrl = catalog + ":" + hsFile.getFilepath();
		String timestamp = hsFile.getParameter(urlTimestamp);
		String secret = hsFile.getParameter(urlAuthority);
		String secretTarget = combineSecret(timestamp, targetUrl);
		return secretTarget.equals(secret) ? 2 : 0;
	}

}
